package com.ldc.wandroid.viewmodel;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;

import com.ldc.common.model.BaseModel;
import com.ldc.common.mvvm.ViewModelBase;
import com.ldc.common.net.Api2Request;
import com.ldc.wandroid.server.ApiServer;

public class AddSharedArticleViewModel extends ViewModelBase {
    private final ApiServer apiServer;

    private final MutableLiveData<BaseModel<Object>> resultData = new MutableLiveData<>();


    public LiveData<BaseModel<Object>> getResult() {
        return resultData;
    }

    public AddSharedArticleViewModel() {
        apiServer = Api2Request.getInstance().createServer(ApiServer.class);
    }


    public void userArticleAdd(String title, String link) {
        apiRequest(apiServer.userArticleAdd(title, link), (status, result, throwable) -> {
            if (status) {
                resultData.setValue(result);
            } else {
                resultData.setValue(null);
            }
        });
    }


}
